package com.jiaanpei.frameproject.modle.user;

import android.content.Context;
import android.util.Log;

import com.jiaanpei.frameproject.app.AppApplication;
import com.jiaanpei.frameproject.gen.UserDao;
import com.jiaanpei.frameproject.modle.bean.db.User;

import java.util.List;

public class UserDbManager {
    private static UserDbManager mInstance;
    private UserDao userDao;

    public UserDbManager(Context context) {
        userDao = AppApplication.getInstance().getDaoSession().getUserDao();
    }

    public static UserDbManager getInstance(Context context) {
        String MSG = "getInstance()";

        if (mInstance == null) {
            synchronized (UserDbManager.class) {
                if (mInstance == null) {
                    mInstance = new UserDbManager(context);
                }
            }
        }



        return mInstance;
    }

    public long insert(User user){
        long rowID = userDao.insert(user);
        return rowID;
    }

    public List<User> queryList(String query){


        List<User> lossAssessmentBeanList = userDao.queryBuilder()
//                .where(UserDao.Properties.Name.eq(query))
                .list();
        return lossAssessmentBeanList;
    }
}
